package com.atguigu.mapreduce.sorting;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;

public class FlowWritableComparator extends WritableComparator {

    /**
     * 将当前比较器对象和指定对象绑定
     */
    public FlowWritableComparator() {
        super(FlowBean.class, true);
    }

    @Override
    public int compare(WritableComparable a, WritableComparable b) {
        FlowBean flowBeanA = (FlowBean) a;
        FlowBean flowBeanB = (FlowBean) b;
        return flowBeanA.getSumFlow().compareTo(flowBeanB.getSumFlow());
    }
}
